<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <div id="app">
        <!-- 直接拼接 -->
        <h2>{{firstName}}  {{lastName}}</h2>
        <!-- 通过定义methods方法 -->
        <h2>{{getFullName()}}</h2>
        <!-- 通过computed计算属性 -->
        <h2>{{fullName}}</h2>
    </div>
</body>
    <script src="../js/vue.js"></script>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                firstName: 'zhang',
                lastName: 'kun'
            },
            computed: {
                //计算属性一般没有set方法，只读属性
                fullName: {
                    get: function () {
                        return this.firstName + '  ' + this.lastName
                    }
                }
            },
            methods :{
                getFullName: function () {
                    return this.firstName + '  ' + this.lastName
                }
            }
        })
    </script>
</html>